package com.sise.wangzhan;

import com.netflix.client.ClientFactory;
import com.netflix.client.http.HttpRequest;
import com.netflix.client.http.HttpResponse;
import com.netflix.config.ConfigurationManager;
import com.netflix.niws.client.http.RestClient;

public class SpringCloudLab03RibbonClientApplication {

    public static void main(String[] args) throws Exception {
        //SpringApplication.run(SpringCloudLab03RibbonClientApplication.class, args);

        ConfigurationManager.loadPropertiesFromResources("application.properties");

        //获取服务名，如果没有就创建
        RestClient client = (RestClient) ClientFactory.getNamedClient("wang-client");

        HttpRequest request = HttpRequest.newBuilder().uri("/person/999").build();
        for (int i = 0; i < 10; i++) {
            HttpResponse response = client.executeWithLoadBalancer(request);
            String entity = response.getEntity(String.class);
            System.out.println(entity);
        }

    }

}
